<template>
  <div class="form-group">
    <form-builder mode="product_menu" :fields="groupFields" :value="value" @update="update">

      <!-- start 质保起算时间 -->
      <template slot="qualityStartTime" slot-scope="{field}">
        <slot name="qualityStartTime" :field="field"></slot>
      </template>
      <!-- start 质保起算时间 -->
      
      <!-- start 质保时长 -->
      <template slot="qualityTime" slot-scope="{field}">
        <slot name="qualityTime" :field="field"></slot>
      </template>
      <!-- start 质保时长 -->
    
    </form-builder>
  </div>
</template>

<script>
import FormMixin from '@src/component/form/mixin/form'

export default {
  name: 'form-group',
  mixins: [FormMixin],
  props: {
    value: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      //
    }
  },
  computed: {
    groupFields() {
      return this.field?.children || this.field?.groupFields || []
    }
  },
  methods: {
    update({ field, newValue }) {
      let { fieldName, displayName } = field
      
      if (this.$appConfig.debug) {
        console.info(`[FormBuilder] ${displayName}(${fieldName}) : ${JSON.stringify(newValue)}`)
      }
      
      let value = {
        ...this.value,
        [fieldName]: newValue
      }
      
      this.$emit('update', { newValue: value, field: this.field })
      this.$emit('input', newValue)
    },
  }
}
</script>

<style lang="scss">
.form-group {
  & > label {
    display: none !important;
  }
}
</style>
